


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_my_app/provider/greeting_state_provider.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class GreetingWidget extends ConsumerWidget {
  const GreetingWidget({super.key});
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    // TODO: implement build
    final String value = ref.watch(greetingStateProvider);
    return SizedBox(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children:  [
            Container(
              width: double.infinity,
              height: 30,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                 color: Colors.red
              ),
              child: Text("======GreetingWidget测试====="),
            ),
            GestureDetector(
              onTap: (){
                ref.read(greetingStateProvider.notifier).state = "New Greeting";
              },
              child: Text("======点击测试====="),
            ),
            Center(
              child: Text(value),
            ),
            SizedBox(height: 10)
          ],
        ),
    );
  }
}